<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图书管理</title>
    <script src="https://unpkg.com/vue@2.7.14/dist/vue.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"></script>
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body>
<div id="app">
    <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="id" label="ID"></el-table-column>
        <el-table-column prop="bookname" label="书名"></el-table-column>
        <el-table-column prop="bookpress" label="出版社"></el-table-column>
        <el-table-column prop="bookdate" label="出版日期"></el-table-column>
        <el-table-column prop="bookauthor" label="作者"></el-table-column>
        <el-table-column fixed="right" label="操作" width="100">
            <template slot-scope="scope">
                <el-button @click="showBook(scope.row)" type="text" size="small">查看</el-button>
                <el-button type="text" size="small">移除</el-button>
            </template>
        </el-table-column>
    </el-table>

    <el-dialog title="图书信息" :visible.sync="dialogFormVisible">
        <el-form :model="book">
            <el-form-item label="书名" :label-width="200">
                <el-input v-model="book.bookname" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="出版社" :label-width="200">
                <el-input v-model="book.bookpress" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="出版日期" :label-width="200">
                <el-input v-model="book.bookdate" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="作者" :label-width="200">
                <el-input v-model="book.bookauthor" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="save">确 定</el-button>
        </div>
    </el-dialog>
</div>
<script>
    var v = new Vue({
        el : "#app",
        data:{
            tableData : [],
            dialogFormVisible : false,
            book : {}
        },
        created(){
            axios.get("QueryServlet").then(res=>{
                this.tableData = res.data;
            })
        },
        methods:{
            save(){
                this.dialogFormVisible = false;
            },
            showBook(book){
                this.dialogFormVisible = true;
                this.book = book;
            }
        }

    })
</script>
</body>
</html>